<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>离职人员工作交接</title>
    <script src="../../../../../res/js/jquery-3.4.1.min.js" charset="utf-8"></script>
    <script src="../../../../../res/js/login_common.js" charset="utf-8"></script>
    <script src="../../../../../res/layui/layui.js" charset="utf-8"></script>
    <script src="../../../../../res/js/Tools.js" charset="utf-8"></script>
    <script src="../../../../../res/js/error.js" charset="utf-8"></script>
    <link rel="shortcut icon" type="image/x-icon" href="../../../../../res/images/favicon.ico">
    <link rel="stylesheet" href="../../../../../res/layui/css/layui.css" media="all">
    <style type="text/css">
        .connect {
            display: flex;
            align-items: center;
            margin-right: 0px !important;
        }

        .connectone {
            margin-top: 3px !important;
            width: calc(100% - 145px) !important;

        }
    </style>
</head>
<body style="padding: 10px">
<h1 align="center" style="margin-bottom: 20px">离职人员工作交接（行政经理签字）</h1>
<form class="layui-form layui-form-pane" action="">
    <div class="layui-form-item">
        <input type="hidden" id="pkDimissionId" name="pkDimissionId"/>
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 145px">姓名</label>
            <div class="layui-input-inline">
                
                <input autocomplete="off" class="layui-input" lay-verify="required" disabled name="personnelName"
                       id="personnelName"
                       type="text"/>
                <input id="personnelId" type="hidden" name="personnelId"/>
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label" style="width: 145px">部门</label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" lay-verify="required" disabled name="departmentName"
                       id="departmentName"
                       type="text"/>
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label" style="width: 145px">岗位</label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" lay-verify="required" disabled name="stationone"
                       id="stationone"
                       type="text"/>
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label" style="width: 145px">入职时间</label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" disabled id="entryTime" lay-verify="date" name="entryTime"
                       placeholder="yyyy-MM-dd"
                       type="text">
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label" style="width: 145px">离职日期</label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" disabled id="dimissionCurrentDate"
                       name="dimissionCurrentDate"
                       placeholder="yyyy-MM-dd HH:mm:ss"
                       type="text">
            </div>
        </div>
    </div>

    <div class="layui-form-item" pane="">
        <label class="layui-form-label " style="width: 160px">离职原因</label>
        <div class="layui-input-block connectone" style="margin-left:160px;">
            <input type="radio" id="dimissionType0" disabled name="dimissionCause" value="0" title="主动离职">
            <input type="radio" id="dimissionType1" disabled name="dimissionCause" value="1" title="辞退" checked="">
            <input type="radio" id="dimissionType2" disabled name="dimissionCause" value="2" title="其他">
        </div>
    </div>
    <!--    <div class="layui-form-item">-->

    <!--    </div>-->
    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 175px">交接人员</label>
        <div class="layui-input-block" style="margin-left:175px">
            <input autocomplete="off" class="layui-input" lay-verify="required" name="personnelIds" disabled
                   id="personnelIds">

        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">部门交接</label>
        <div class="layui-input-block">


            <div class="layui-form-item">
                <div class="layui-inline connect">
                    <label class="layui-form-label" style="width: 145px">经管工作</label>
                    <div class="layui-input-inline connectone">
                        <input autocomplete="off" class="layui-input" lay-verify="required"
                               name="handoverDepartmentWork"
                               id="handoverDepartmentWork"
                               disabled
                               type="text"/>
                    </div>
                </div>

                <div class="layui-inline connect">
                    <label class="layui-form-label" style="width: 145px">文件资料</label>
                    <div class="layui-input-inline connectone">
                        <input autocomplete="off" class="layui-input" lay-verify="required"
                               id="handoverDepartmentDocumentation"
                               name="handoverDepartmentDocumentation"
                               disabled
                               type="text"/>
                    </div>
                </div>

                <div class="layui-inline connect">
                    <label class="layui-form-label" style="width:300px">业务协作方有效联络人及联系电话</label>
                    <div class="layui-input-inline connectone">
                        <input autocomplete="off" class="layui-input" lay-verify="required"
                               name="handoverDepartmenContact"
                               disabled
                               id="handoverDepartmenContact"
                               type="text"/>
                    </div>
                </div>

                <div class="layui-form-item" pane="">
                    <label class="layui-form-label" style="width: 145px">电脑涉密资料确认</label>
                    <div class="layui-input-block " style="margin-left: 145px">
                        <input type="radio" id="handoverDepartmentClassifiedInformation0" disabled
                               name="handoverDepartmentClassifiedInformation" value="0" title="已确认">
                        <input type="radio" id="handoverDepartmentClassifiedInformation1" disabled
                               name="handoverDepartmentClassifiedInformation" value="1" title="待确认"
                               checked="">
                    </div>
                </div>

                <div class="layui-inline connect">
                    <label class="layui-form-label" style="width: 145px">其他</label>
                    <div class="layui-input-inline connectone">
                        <input autocomplete="off" class="layui-input" lay-verify="required"
                               name="handoverOtherMatters"
                               disabled
                               id="handoverOtherMatters"
                               type="text"/>
                    </div>
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入内容" id="handoverDepartmentRemark" disabled
                                  class="layui-textarea"></textarea>
                    </div>
                </div>
            </div>

        </div>
    </div>


    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">行政交接</label>
        <div class="layui-input-block">


            <div class="layui-form-item">
                <div class="layui-inline connect">
                    <label class="layui-form-label" style="width: 145px">办公用品说明</label>
                    <div class="layui-input-inline connectone">
                        <input autocomplete="off" class="layui-input" lay-verify="required"
                               name="handoverOfficeSupplies"
                               disabled
                               id="handoverOfficeSupplies"
                               type="text"/>
                    </div>
                </div>

                <div class="layui-form-item" style="display: flex">
                    <label class="layui-form-label" style="width: 145px">交接人员</label>
                    <div class="layui-input-block" style="margin-top: 1px; width: calc(100% - 145px)">
                        <input autocomplete="off" class="layui-input" lay-verify="required" name="handoverReceiver"
                               disabled id="handoverReceiver">
                    </div>
                </div>
                <div class="layui-inline connect">
                    <label class="layui-form-label" style="width: 145px">公司账号</label>
                    <div class="layui-input-inline connectone">
                        <input autocomplete="off" class="layui-input" lay-verify="required" id="handoverAccountPassword"
                               name="handoverAccountPassword" placeholder="请输入公司相关的登陆账号密码等"
                               disabled
                               type="text"/>
                    </div>
                </div>
                <div class="layui-form-item" pane="">
                    <label class="layui-form-label" style="width: 145px">是否违约</label>
                    <div class="layui-input-block " style="margin-left: 145px">
                        <input type="radio" id="handoverRenege0" disabled name="handoverRenege" value="0" title="是">
                        <input type="radio" id="handoverRenege1" disabled name="handoverRenege" value="1" title="否"
                               checked="">
                    </div>
                </div>

                <div class="layui-inline connect">
                    <label class="layui-form-label" style="width: 145px">其它</label>
                    <div class="layui-input-inline connectone">
                        <input autocomplete="off" class="layui-input" lay-verify="required"
                               name="handoverOthers"
                               disabled
                               id="handoverOthers"
                               type="text"/>
                    </div>
                </div>

                <div class="layui-inline connect">
                    <label class="layui-form-label" style="width: 145px">本月考勤情况</label>
                    <div class="layui-input-inline connectone">
                        <input autocomplete="off" disabled class="layui-input" lay-verify="required"
                               name="attendance"
                               id="attendance"
                               type="text"/>
                    </div>
                </div>

                <div class="layui-inline connect">
                    <label class="layui-form-label" style="width: 145px">社保停缴时间</label>
                    <div class="layui-input-inline connectone">
                        <input autocomplete="off" disabled class="layui-input" id="stopPaying" lay-verify="date"
                               name="stopPaying"
                               placeholder="yyyy-MM-dd"
                               type="text">
                    </div>
                </div>

                <div class="layui-inline connect">
                    <label class="layui-form-label" style="width: 145px">薪资截止日</label>
                    <div class="layui-input-inline connectone">
                        <input autocomplete="off" class="layui-input" id="payrollDeadline"
                               name="payrollDeadline"
                               disabled
                               placeholder="yyyy-MM-dd HH:mm:ss"
                               type="text">
                    </div>
                </div>

                <div class="layui-inline connect">
                    <label class="layui-form-label" style="width: 200px">最终工资结算及发放时间</label>
                    <div class="layui-input-inline connectone">
                        <input autocomplete="off" class="layui-input" id="paymentTime"
                               name="paymentTime"
                               disabled
                               placeholder="yyyy-MM-dd HH:mm:ss"
                               type="text">
                    </div>
                </div>

                <div class="layui-form-item" pane="">
                    <label class="layui-form-label" style="width: 145px">开具离职证明</label>
                    <div class="layui-input-block" style="margin-left: 145px">
                        <input type="radio" id="separationProve0" disabled name="separationProve" value="0" title="己开具">
                        <input type="radio" id="separationProve1" disabled name="separationProve" value="1" title="己领取"
                               checked="">
                    </div>
                </div>
            </div>
        </div>
    </div>

    <hr/>

</form>

<div class="layui-form-item">
    <div class="site-demo-button" id="layerDemo">
        <button type="submit" class="layui-btn site-demo-active" lay-submit="" id="demo1">通过</button>
        <button data-method="offset" data-type="auto" class="layui-btn layui-btn-normal">不通过</button>
    </div>
</div>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>流程日志</legend>
</fieldset>
<ul class="layui-timeline" id="schedule"></ul>
<script>
    var table2;
    // 修改赋值
    let pkDimissionId = getQueryString("pkDimissionId");
    var id = getQueryString("pkDimissionHandoverId");
    console.log(id);
    layui.use(['form', 'table', 'layedit', 'laydate', 'layer'], function () {
        var table = layui.table
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
            , form = layui.form;
        // 入职日期
        laydate.render({
            elem: '#entryTime'
        });
        // 离职申请日期
        laydate.render({
            elem: '#dimissionCurrentDate'
        });
        // 正式离职日期
        laydate.render({
            elem: '#dimissionTime'
        });

        let res = getAjaxById(getRootPath() + "OaPersonnelAction/getUser");
        var resdata = getAjaxById(getRootPath() + "OaDimissionHandoverAction/selectById/" + id);
        $("#personnelId").val(res.pkPersonnelId);
        //离职原因
        $("input[name=dimissionType][value='0']").attr("checked", resdata.dimissionType == 0 ? true : false); // 离职类型 试用期内离职
        $("input[name=dimissionType][value='1']").attr("checked", resdata.dimissionType == 1 ? true : false); // 离职类型 合同期内离职
        $("input[name=dimissionType][value='2']").attr("checked", resdata.dimissionType == 2 ? true : false); // 离职类型 合同到期
        //离职人员名称
        $("#personnelName").val(resdata.personnelName);
        // 离职人员部门
        $("#departmentName").val(resdata.departmentName);
        //离职人员岗位
        $("#stationone").val(resdata.postName);
        // 填表日期
        $("#entryTime").val(dateFormat('yyyy-MM-dd', new Date(resdata.entryTime)));
        //正式离职日期
        $("#dimissionCurrentDate").val(dateFormat('yyyy-MM-dd', new Date(resdata.dimissionTime)));
        //交接人员
        $("#personnelIds").val(resdata.createdBy);
        //经管工作
        $("#handoverDepartmentWork").val(resdata.handoverDepartmentWork);
        //文件资料
        $("#handoverDepartmentDocumentation").val(resdata.handoverDepartmentDocumentation);
        //业务协作方有效联络人及联系电话
        $("#handoverDepartmenContact").val(resdata.handoverDepartmenContact);
        //电脑涉密资料确认
        $("input[name=handoverDepartmentClassifiedInformation][value='0']").attr("checked", resdata.handoverDepartmentClassifiedInformation == 0 ? true : false); // 离职类型 试用期内离职
        $("input[name=handoverDepartmentClassifiedInformation][value='1']").attr("checked", resdata.handoverDepartmentClassifiedInformation == 1 ? true : false); // 离职类型 合同期内离职
        //其他
        $("#handoverOtherMatters").val(resdata.handoverOtherMatters);
        //备注
        $("#handoverDepartmentRemark").val(resdata.handoverDepartmentRemark);


        //办公用品说明
        $("#handoverOfficeSupplies").val(resdata.handoverOfficeSupplies);
        //行政交接人员
        $("#handoverReceiver").val(resdata.updatedBy);
        //公司账号
        $("#handoverAccountPassword").val(resdata.handoverAccountPassword);
        //其他
        $("#handoverOthers").val(resdata.handoverOthers);
        //是否违约
        $("input[name=handoverRenege][value='0']").attr("checked", resdata.handoverRenege == 0 ? true : false); // 离职类型 试用期内离职
        $("input[name=handoverRenege][value='1']").attr("checked", resdata.handoverRenege == 1 ? true : false); // 离职类型 合同期内离职
        //离职证明
        $("input[name=separationProve][value='0']").attr("checked", resdata.separationProve == 0 ? true : false); // 离职类型 试用期内离职
        $("input[name=separationProve][value='1']").attr("checked", resdata.separationProve == 1 ? true : false); // 离职类型 合同期内离职
        //考勤
        $("#attendance").val(resdata.attendance);
        //社保

        $("#stopPaying").val(dateFormat('yyyy-MM-dd', new Date(resdata.stopPaying)));
        //薪资
        $("#payrollDeadline").val(dateFormat('yyyy-MM-dd', new Date(resdata.payrollDeadline)));
        //结算
        $("#paymentTime").val(dateFormat('yyyy-MM-dd', new Date(resdata.paymentTime)));
        form.render();
        const resss = getAjaxById(getRootPath() + "OaFlowAction/selectFlowSchedule/" + id);
        $("#schedule").html("");
        $.each(resss, function (index, item) {
            if (item.createdBy) {
                $("#schedule").append('<li class="layui-timeline-item">\n' +
                    '        <i class="layui-icon layui-timeline-axis"></i>\n' +
                    '        <div class="layui-timeline-content layui-text">\n' +
                    '            <h3 class="layui-timeline-title">' + dateFormat('yyyy-MM-dd hh:mm:ss', new Date(item.createdTime)) + '&nbsp;&nbsp;&nbsp;' + item.flowName + '</h3>\n' +
                    '            <p>' + item.formReason + '</p>\n' +
                    '            <p>操作人：' + item.createdBy + '</p>\n' +
                    '        </div>\n' +
                    '    </li>')

            } else {
                $("#schedule").append('<li class="layui-timeline-item">\n' +
                    '        <i class="layui-icon layui-timeline-axis"></i>\n' +
                    '        <div class="layui-timeline-content layui-text">\n' +
                    '            <h3 class="layui-timeline-title">' + dateFormat('yyyy-MM-dd hh:mm:ss', new Date(item.createdTime)) + '&nbsp;&nbsp;&nbsp;' + item.flowName + '</h3>\n' +
                    '            <p>' + item.formReason + '</p>\n' +
                    '        </div>\n' +
                    '    </li>')
            }
        });

    });
    //独立版的layer无需执行这一句
    var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句

    //触发事件
    var active = {
        offset: function (othis) {
            var type = othis.data('type')
                , text = othis.text();

            layer.open({
                type: 1
                ,
                offset: type //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
                ,
                id: 'layerDemo' + type //防止重复弹出
                ,
                content: '<div style="padding: 20px 20px;"> <textarea placeholder="请填写不通过的原因" id="departmentLeadership" class="layui-textarea"></textarea></div>'
                ,
                btn: '确认'
                ,
                btnAlign: 'c' //按钮居中
                ,
                shade: 0 //不显示遮罩
                ,
                yes: function (res) {
                    let data = {
                        'pkDimissionHandoverId': id,
                        'departmentLeadership': $("#departmentLeadership").val()
                    };
                    const postres = postAjax(getRootPath() + "/OaDimissionHandoverAction/managerNoPass", data);
                    console.log(postres);
                    if (postres === 1) {
                        layer.msg('暂存成功3秒后关闭当前窗口', {icon: 1});
                        setTimeout(function () {
                            formClose();
                        }, 3000);
                        setTimeout(function () {
                            parent.layui.table.reload('test');//刷新父页面
                            //window.parent.location.reload();//刷新父页面
                            const index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                            parent.layer.close(index);
                        }, 3000);
                        //window.location.reload();//刷新页面
                    } else if (postres=== 500) {
                        error('500');
                    } else {
                        layer.msg("新增失败");
                    }

                }
            });
        }
    };

    $('#layerDemo .layui-btn').on('click', function () {
        var othis = $(this), method = othis.data('method');
        active[method] ? active[method].call(this, othis) : '';
    });
    $("#demo1").on("click", function () {
        // 单击之后提交按钮不可选,防止重复提交
        var DISABLED = 'layui-btn-disabled';
        // 增加样式
        $('.site-demo-active').addClass(DISABLED);
        // 增加属性
        $('.site-demo-active').attr('disabled', 'disabled');
        let data = {
            'pkDimissionHandoverId': id
        };
        const res = postAjax(getRootPath() + "OaDimissionHandoverAction/managerPass", data);
        console.log(res);
        if (res == 1) {
            layer.msg('暂存成功3秒后关闭当前窗口', {icon: 1});
            setTimeout(function () {
                formClose();
            }, 3000);
            setTimeout(function () {
                parent.layui.table.reload('test');//刷新父页面
                //window.parent.location.reload();//刷新父页面
                const index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                parent.layer.close(index);
            }, 3000);
            //window.location.reload();//刷新页面
        } else if (res == 500) {
            error('500');
        } else {
            layer.msg("新增失败");
        }
    })
</script>
</body>
</html>